<template>
	<view class="all">
		<view class="head flex_sp">
			<view class="box flex_sp" @click="showpop1()">
				<input type="text" placeholder="年/月/日" v-model="starttime" />
				<image src="../../../static/index/card.png" mode=""></image>
			</view>
			<view class="aline">
				-
			</view>
			<view class="box flex_sp" @click="showpop2()">
				<input type="text" placeholder="年/月/日" v-model="endtime" />
				<image src="../../../static/index/card.png" mode=""></image>
			</view>
		</view>
		<view class="center">
			<view class="header flex">
				<view class="box" v-for="(item , index) in listss" :key="index">
					{{item}}
				</view>
			</view>
			<view class="foot flex_sp">
				<view class="left">
					<view class="info" v-for="(item , index) in list.record" :key="index">
						{{item.date}}
					</view>
				</view>
				<view class="right flex">
					<view class="every" v-for="(item , index) in list.record" :key="index">
						<view class="list">
							{{item.achievement}}
						</view>
						<view class="list">
							{{item.project}}
						</view>
						<view class="list">
							{{item.fare}}
						</view>
						<view class="list">
							{{item.singular}}
						</view>
					</view>
				</view>
			</view>
		</view>
		<u-datetime-picker :show="show1" v-model="v1" mode="date" @confirm="confirm1"
			@cancel="cancel1"></u-datetime-picker>
		<u-datetime-picker :show="show2" v-model="v2" mode="date" @confirm="confirm2"
			@cancel="cancel2"></u-datetime-picker>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show1: false,
				v1: Number(new Date()),
				show2: false,
				v2: Number(new Date()),
				starttime: "",
				endtime: "",
				listss: ['日期', '业绩(元)', '项目(元)', '车费(元)', '订单'],
				list:{}
			};
		},
		onLoad() {
			this.gettime()
		},
		methods: {
			async gettime(){
				const res = this.$api("/business/user/history",'post',{
					start_time:this.starttime,
					end_time:this.endtime
				}).then((res)=>{
					console.log(res);
					console.log(res.data.data);
					this.list = res.data.data
				}).catch((err)=>{
					console.log(err);
				})
			},
			showpop1() {
				this.show1 = true
			},
			showpop2() {
				this.show2 = true
			},
			confirm1(e) {
				console.log(e);
				this.show1 = false
				let a = new Date(e.value)
				this.starttime = a.getFullYear() + "-" + a.getMonth() + "-" + a.getDate()
				if (this.starttime && this.endtime) {
					this.gettime()
				}
			},
			confirm2(e) {
				console.log(e);
				this.show2 = false
				let b = new Date(e.value)
				this.endtime = b.getFullYear() + "-" + b.getMonth() + "-" + b.getDate()
				if (this.starttime && this.endtime) {
					this.gettime()
				}
			},
			cancel1() {
				this.show1 = false
			},
			cancel2() {
				this.show2 = false
			}
		}
	}
</script>

<style lang="scss" scoped>
	.all {
		padding: 15px;

		.head {
			.aline {
				margin: 0 10px;
			}

			.box {
				padding: 10px;
				border-radius: 5px;
				border: 1px solid #999999;

				image {
					width: 18px;
					height: 18px;
				}

				input {
					font-size: 12px;
					font-weight: 400;
					color: #999999;
				}
			}
		}

		.center {
			margin: 20px 0;
			display: flex;
			flex-direction: column;

			.header {
				flex: 1;
				background-color: #FB774B;
				padding: 10px;
				background: #FB774B;
				border-radius: 10px 10px 0px 0px;
				box-sizing: border-box;

				.box {

					box-sizing: border-box;
					border-right: 1px solid #fff;
					flex: 1;
					text-align: center;
					font-size: 12px;
					font-family: PingFang SC, PingFang SC;
					font-weight: bold;
					color: #FFFFFF;
				}
			}

			.foot {
				flex: 1;

				.left {
					box-sizing: border-box;
					background-color: rgb(253, 213, 200);
					opacity: .3;
					font-size: 12px;
					box-sizing: border-box;
					display: flex;
					flex-direction: column;
					color: #1A1A1A;

					.info {
						padding: 10px;
						font-size: 10px;
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						flex: 1;
						margin: 5px 0;
					}
				}

				.right {
					box-sizing: border-box;
					background-color: #fff;
					flex: 1;
					height: 100%;
					display: flex;
					flex-direction: column;

					.every {
						width: 100%;
						text-align: center;
						display: flex;
						// flex-direction: column;

						.list {
							padding: 15px 0;
							flex: 1;
							border: 1px solid #eeeeee;
							// display: flex;
							// flex-direction: column;
							font-size: 10px;
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							color: #333333;
						}
					}
				}
			}
		}
	}
</style>